package pearson.automation.forms.courseDetails.module;

import org.openqa.selenium.By;

import framework.elements.Label;
import framework.elements.TextBox;

/**
 * 
 * This form represents Objectives part in the section's content form
 * 
 */
public class ObjectiveConcepts extends SectionForm {

    private static final String titleLocatorTemplate = 
        "//h1[text()='%1$s']";
    private static final String subtitleLocatorTemplate = 
        "//div[@class='section_container'][contains(.,'%1$s')]"
      + "//h3[@data-editable-ref]";
    private static final String editorSuffix = "/../textarea";
    private static final String chapterLocatorTemplate = 
        "//div[@class='section_container'][contains(.,'%1$s')]"
      + "//ul[@data-content-ref]//p[contains(.,'%2$s')]";
    private final String name;

    public ObjectiveConcepts(String name) {
    super(By.xpath(String.format(titleLocatorTemplate, name)), name);

    this.name = name;
    title = new Label(By.xpath(
            String.format(titleLocatorTemplate, name)), "Title");
    subtitle = new Label(By.xpath(
            String.format(subtitleLocatorTemplate, name)), "Subtitle");
    subtitleEditor = new TextBox(By.xpath(
            String.format(subtitleLocatorTemplate, name) + editorSuffix),
            "Subtitle");
    chapter = new Label(By.xpath(
            String.format(chapterLocatorTemplate, name, "")), "Chapter");
    chapterXpath = String.format(chapterLocatorTemplate, name, "%1$s");
    }

}
